package mo.offer_version2;

public class L14_1 {

    public int cuttingRope(int n) {
        int[] dp = new int[n+1];
        dp[0] = 0;
        dp[1] = 1;
        dp[2] = 1;

        for (int i = 3; i <= n; i++) {
            for (int j = 1; j < i; j++) {
                dp[i] = Math.max(dp[i], Math.max(dp[i-j], i-j)*j);
            }

        }

        return dp[n];
    }

    public static void main(String[] args) {
        L14_1 test = new L14_1();
        System.out.println(test.cuttingRope(10));
    }
}
